package org.samcolon.springsecuritydemo1;

import org.springframework.security.authentication.LockedException;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;

import java.util.Random;

/**
 * @Description:
 * @author: Sam.zhang
 * @date: 2022/2/14 - 0:40
 */
public class MyUserDetailsService implements UserDetailsService {
    @Override
    public UserDetails loadUserByUsername(String s) throws UsernameNotFoundException {
        // 此处获得用户信息
        if(new Random().nextBoolean()){

        } else {
            throw new LockedException("用户已锁定，请联系管理员");
        }
        return null;
    }
}
